package com.ftg.learn.chapter10;

/**
 * @author KangJx
 * @date 2021/7/16
 */
public class aa {

    public static void main(String[] args) {

        int[] oldArr=new int[]{1,3,4,5,0,0,6,6,0,5,4,7,6,7,0,5};
        int no=0,b=0;
        for(int i=0,len=oldArr.length;i<len;i++) {
            if (oldArr[i] != 0) {
                no++;
            } else {
                for (int j = i, jlen = oldArr.length-1; j < jlen; j++) {
                    if(oldArr[j]!=0) {
                        oldArr[j] = oldArr[j + 1];
                    }else{
                        for(int k=j,klen=oldArr.length;k<klen;k++){
                            if(oldArr[k]!=0){
                                b=k;
                                break;
                            }
                        }
                        oldArr[j]=oldArr[b];
                    }
                }

            }
        }


        int[] newArr=new int[no];
        for(int i=0,len=newArr.length;i<len;i++){
            newArr[i]=oldArr[i];
        }
        for(int n:newArr){
            System.out.print(n+"\t");
        }
    }
}
